package com.clkj.sunhelp.mvp.publicityshow.publicityofshenpiprocess;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.common.IntentKey;
import com.clkj.sunhelp.mvp.base.BaseActivity;
import com.clkj.sunhelp.util.ToastUtil;
import com.jakewharton.rxbinding.view.RxView;

import rx.functions.Action1;
import rx.functions.Func1;

/**
 * 审批节点公示查询界面
 * Created by Administrator on 2017/3/31.
 */

public class ActivityPublicityOfShenPiProcessSearchView extends BaseActivity {

    private EditText etInputRealName;
    private EditText etInputIdcardno;
    private TextView tvSubmit;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_publicity_of_shenpi_process_search_view);
        initTitleWithRightTvOrIv(null,null,"审批节点公示",true,null,null);
        initData();
        assignView();
        initView();
    }

    @Override
    public void initData() {

    }

    @Override
    public void assignView() {


        etInputRealName = (EditText) findViewById(R.id.et_input_real_name);
        etInputIdcardno = (EditText) findViewById(R.id.et_input_idcardno);
        tvSubmit = (TextView) findViewById(R.id.tv_submit);

    }

    @Override
    public void initView() {
        RxView.clicks(tvSubmit)
                .filter(new Func1<Void, Boolean>() {
                    @Override
                    public Boolean call(Void aVoid) {
                        boolean result = false;
                        if (TextUtils.isEmpty(etInputRealName.getText().toString()) == true
                                && TextUtils.isEmpty(etInputIdcardno.getText().toString()) == true) {
                            ToastUtil.showShort(ActivityPublicityOfShenPiProcessSearchView.this, "请输入您查询的真实姓名或者身份证号码");
                        } else {
                            result = true;
                        }


                        return result;
                    }
                }).subscribe(new Action1<Void>() {
            @Override
            public void call(Void aVoid) {
                Intent toShowShenPiProcessInfo = new Intent(ActivityPublicityOfShenPiProcessSearchView.this, ActivityPublicityOfShenPiProcessShowView.class);
                toShowShenPiProcessInfo.putExtra(IntentKey.INTENT_KEY_PERSONNAME, etInputRealName.getText().toString());
                toShowShenPiProcessInfo.putExtra(IntentKey.INTENT_KEY_IDCARD_NO, etInputIdcardno.getText().toString());
                startActivity(toShowShenPiProcessInfo);
            }
        });
    }
}
